#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<ctype.h>
#include<limits.h>
#include<assert.h>
int myAtoi(char* s)
{
    int ret = 0;
    while (*s == ' ')
    {
        s++;
    }
    int flag = 1;
    if (*s == '-')
    {
        flag = -1;
        s++;
    }
    else if (*s == '+')
    {
        s++;
    }
    while (isdigit(*s))
    {
        if (ret >= INT_MAX / 10)
        {
            if (ret == INT_MAX / 10 && (*s - '0') <= 7)
            {
                ;
            }
            else
            {
                return INT_MAX;
            }
        }
        else if (ret <= INT_MIN / 10)
        {
            if (ret == INT_MIN / 10 && (*s - '0') <= 8)
            {
                ;
            }
            else
            {
                return INT_MIN;
            }
        }
        ret = ret * 10 + (*s - '0') * flag;
        s++;
    }
    return ret;
}
int main()
{
    char str[] = "-91283472332";
    printf("%d\n", myAtoi(str));
    return 0;
}